<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>


</head>

<body>
    <div id="box">

        <span>{{getfullName()}}</span>
        <span>{{getfullName()}}</span>
        <span>{{getfullName()}}</span>
        <span>{{getfullName()}}</span>
        <span>{{getfullName()}}</span>

        <span>{{fullName}}</span>
        <span>{{fullName}}</span>
        <span>{{fullName}}</span>
        <span>{{fullName}}</span>
        <span>{{fullName}}</span>

    </div>

</body>

<script src="https://cdn.bootcss.com/vue/2.6.11/vue.js"></script>
<script>
    new Vue({
        el: '#box',
        data: {
            firstName: '洪',
            lastName: '小横',
            c: 0,
            m: 0,
        },
        //方法执行5次
        methods: {
            getfullName: function() {
                console.log('getfullName');
                return this.firstName + ' ' + this.lastName;
            }
        },
        //计算属性执行一次 在不改变属性的状态的时候
        //采用了缓存机制性能更高
        computed: {
            fullName: function() {
                console.log('fullName');
                return this.firstName + ' ' + this.lastName;
            }
        }

    })
</script>

</html>